
<!-- IF  S_USE_HTML5_CANVAS -->	
<script src="{T_TEMPLATE_PATH}/RGraph/RGraph.common.core.js" ></script>
<script src="{T_TEMPLATE_PATH}/RGraph/RGraph.common.dynamic.js" ></script>
<script src="{T_TEMPLATE_PATH}/RGraph/RGraph.tooltips.js" ></script>
<script src="{T_TEMPLATE_PATH}/RGraph/RGraph.pie.js" ></script>
<!-- ENDIF -->

<!-- IF IN_FB_IFRAME -->
	<script type="text/javascript" src="../ofc/js/json/json2.js"></script>
	<script type="text/javascript" src="../ofc/js/swfobject.js"></script>
	<script type="text/javascript">
	swfobject.embedSWF("../ofc/open-flash-chart.swf", "holding_stock_chart", "400", "320", "9.0.0", "expressInstall.swf",  {"get-data":"get_data_holding_stock"} );
	</script>
<!-- ELSE -->		
	<script type="text/javascript" src="ofc/js/json/json2.js"></script>
	<script type="text/javascript" src="ofc/js/swfobject.js"></script>
	<script type="text/javascript">
	swfobject.embedSWF("ofc/open-flash-chart.swf", "holding_stock_chart", "500", "400", "9.0.0", "expressInstall.swf",  {"get-data":"get_data_holding_stock"} );
	</script>
<!-- ENDIF -->


<script type="text/javascript">
    
function get_data_holding_stock()
{
    //alert( 'reading data - holding stock' );
    return JSON.stringify(holding_stock_data);
}

var holding_stock_data = {HOLDING_STOCK_JASON_STRING};

</script>



<div class="panel" > 
	<div class="inner"><span class="corners-top"><span></span></span> 
	<h2><!-- IF S_SHOW_QUERY_USERNAME_IN_HOLDING_STOCK_LIST  -->{U_QUERY_USERNAME} -  <!-- ENDIF -->{L_SV_ASSEST_LIST} &nbsp <img title="{L_SV_ASSET_LIST_INFO}" src="{T_IMAGES_PATH}icons/smile/info.gif" alt="info" /> </h2> 
	
	</div>
	
	<table border="0" cellpadding="5" cellspacing="5">
		<tr title="{L_SV_ASSET_LIST_TIP_TOTAL_MARKET_VALUE}">
			<td ><p>
				{L_SV_TOTAL_MARKET_VALUE}&nbsp; : &nbsp;
			</p></td>
			<td><p>	
				{TOTAL_VALUE_IN_HOLDING_STOCK_LIST} 
			</p></td>
			<td></td>
			<td></td>
			<td>
				
			</td>
		</tr>
		<tr title="{L_SV_ASSET_LIST_TIP_MONEY}">
			<td></td>
			<td ><p>				
				{L_SV_MONEY}&nbsp; : &nbsp;
			</p></td>
			<td><p>	
				{MONEY_IN_HOLDING_STOCK_LIST} ({MONEY_PERCENTAGE_IN_HOLDING_STOCK_LIST}%)
			</p></td>
		</tr>
		<tr title="{L_SV_ASSET_LIST_TIP_MARKET_VALUE_OF_HOLDING_STOCK}">
			<td></td>
			<td ><p>				
				{L_SV_MARKET_VALUE_OF_HOLDING_STOCK}&nbsp; : &nbsp;
			</p></td>
			<td><p>	
				{VALUE_IN_HOLDING_STOCK_LIST} ({VALUE_PERCENTAGE_IN_HOLDING_STOCK_LIST}%)
			</p></td>
		</tr>
		
		<!-- IF S_SHORT_STOCK_LIST  -->
		<tr title="{L_SV_ASSET_LIST_TIP_SHORT_PART} &#13; &#13;{L_SV_MAINTENANCE_RATE}:{MAINTENANCE_RATE}% &#13;{L_SV_MAINTENANCE_RATE_TIP}">
			<td></td>
			<td ><p>		
				{L_SV_SHORT_PART} &nbsp; : &nbsp;
			</p></td>
			<td><p>	
				{SHORT_IN_HOLDING_STOCK_LIST} ({SHORT_PERCENTAGE_IN_HOLDING_STOCK_LIST}%)
			</p></td>
		</tr>
		
		<tr title="{L_SV_ASSET_LIST_TIP_DEPOSIT}">
			<td></td>
			<td></td>
			<td ><p>				
				{L_SV_DEPOSIT} &nbsp; : &nbsp;
			</p></td>
			<td><p>	
				{DEPOSIT_IN_HOLDING_STOCK_LIST} 
			</p></td>
		</tr>
		<tr title="{L_SV_ASSET_LIST_TIP_SHORT_PART_GAIN_OR_LOSS}">
			<td></td>
			<td></td>
			<td ><p>		
				{L_SV_SHORT_PART_GAIN_OR_LOSS}&nbsp; : &nbsp;
			</p></td>
			<td><p>	
				{GAIN_OR_LOSS_IN_HOLDING_STOCK_LIST} 
			</p></td>
		</tr>
		<!-- ENDIF  -->
		
		
	</table>
	

<!-- IF ! S_USE_HTML5_CANVAS -->	

<div id="holding_stock_chart"></div>

<!-- ELSE -->	
	
<canvas id="holding_stock_canvas" width="500" height="250"> </canvas>   </td>

<script>
var pie = new RGraph.Pie('holding_stock_canvas', [{HOLDING_STOCK_VALUE_PERCENT_HTML5}])
        .set('exploded', [20])
        .set('shadow', true)
        .set('shadow.blur', 10)
        .set('shadow.color', '#aaa')
        .set('shadow.offsetx', 0)
        .set('shadow.offsety', 0)
        .set('strokestyle', 'rgba(0,0,0,0)')
        .set('labels', ['{HOLDING_STOCK_VALUE_LABEL_HTML5}'])
        //.set('colors',[ '#548AA6', '#5E5347', '#9D463B', '#C86876','#90AA9B', '#CB794C','#98A833','#D83526', '#CEB307'  ])
        .set('colors',[ '#74AAC6', '#7E7367', '#BD665B', '#E88896','#B0CABB', '#EB996C','#B8C853','#F85546', '#EED327', '#74AAC6', '#7E7367', '#BD665B', '#E88896','#B0CABB', '#EB996C','#B8C853','#F85546', '#EED327', '#74AAC6', '#7E7367', '#BD665B', '#E88896','#B0CABB', '#EB996C','#B8C853','#F85546', '#EED327', '#74AAC6', '#7E7367', '#BD665B', '#E88896','#B0CABB', '#EB996C','#B8C853','#F85546', '#EED327', '#74AAC6', '#7E7367', '#BD665B', '#E88896','#B0CABB', '#EB996C','#B8C853','#F85546', '#EED327', '#74AAC6', '#7E7367', '#BD665B', '#E88896','#B0CABB', '#EB996C','#B8C853','#F85546', '#EED327' ])
        
        .draw();

</script>
<!-- ENDIF  -->

	
	<!-- IF S_HOLDING_STOCK_LIST  -->
	<table border="0" cellpadding="5" cellspacing="5">
		<tr>
		<p>{L_SV_HOLDING_STOCK}</p>
		</tr>
		<tr>			
			<td><p>{L_SV_CORP_NAME}</p></td>
			<td title="{L_SV_ASSET_LIST_TIP_NUMBER}" class="share_number"><p>{L_SV_NUMBER}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_COST}" class="share_price"><p>{L_SV_COST}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_REFERED_PRICE}" class="share_price"><p>{L_SV_REFERED_PRICE}</p></td>						
			<td title="{L_SV_ASSET_LIST_TIP_DIFFERENCE_PRICE}" class="share_price"><p>{L_SV_DIFFERENCE_PRICE}</p></td>	
			
			<td title="{L_SV_ASSET_LIST_TIP_MARKET_VALUE}" class="market_value"><p>{L_SV_MARKET_VALUE}</p></td>				
			
			<!-- IF S_ALLOW_EDIT_STOP_LOSS_PROFIT	  -->					
			<td title="" class="stop_loss_profit"> {L_SV_STOP_LOSS}  </td>
			<td title="" class="stop_loss_profit"> {L_SV_STOP_PROFIT}  </td>
			<td title="" class="edit_stop_loss_profit"> </td>			
			<!-- ENDIF -->
			
			<td title="{L_SV_ASSET_LIST_TIP_MORE_INFO}" class="more_info"><p>{L_SV_MORE_INFO}</p></td>	
			
			<!-- IF S_SHOW_NOTE_IN_ASSET_LIST	  -->					
			<td title="{L_SV_ASSET_LIST_TIP_NOTE}" class="edit_note"><p> {L_SV_NOTE} </p> </td>
			<!-- ENDIF -->
			
			
			
		</tr>
		<!-- BEGIN holding_stock_list -->
		<tr>
			<td><p><a href=" http://mops.twse.com.tw/mops/web/t146sb03?step=1&firstin=1&off=1&keyword4=&code1=&TYPEK2=&checkbtn=&queryName=co_id&TYPEK=all&isnew=true&co_id={holding_stock_list.CORP_ID}" target=_blank>{holding_stock_list.CORP_NAME}({holding_stock_list.CORP_ID})</a></p></td>
			<td title="{L_SV_ASSET_LIST_TIP_NUMBER}"  class="share_number"><p>{holding_stock_list.NUMBER}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_COST}" class="share_price"><p>{holding_stock_list.COST}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_REFERED_PRICE}" class="share_price"><p><a href="http://mis.twse.com.tw/stock/fibest.jsp?stock={holding_stock_list.CORP_ID}" target=_blank>{holding_stock_list.REFERED_PRICE}</a></p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_DIFFERENCE_PRICE}   ({holding_stock_list.DIFFERENCE_PRICE_PERCENT}<!-- IF holding_stock_list.COST != 0 -->%)<!-- ENDIF -->" class="share_price_diff"><p>{holding_stock_list.DIFFERENCE_PRICE} ({holding_stock_list.DIFFERENCE_PRICE_PERCENT}<!-- IF holding_stock_list.COST != 0 -->%)<!-- ENDIF --></p></td>
			
			<td title="{L_SV_ASSET_LIST_TIP_MARKET_VALUE}    ({holding_stock_list.MARKET_VALUE_PERCENT}<!-- IF VALUE_IN_HOLDING_STOCK_LIST != 0 -->%)<!-- ENDIF -->" class="market_value"><p>{holding_stock_list.MARKET_VALUE}</p></td>
						
			<!-- IF S_ALLOW_EDIT_STOP_LOSS_PROFIT	  -->
			<td class="stop_loss_profit" >
				<span id="holding-stop-loss-{holding_stock_list.CORP_ID}">						
					<!-- IF holding_stock_list.STOP_LOSS != 0	  -->
						<img src="{T_IMAGES_PATH}down_bar.png"  width="12" height="12" /> 
							
						<!-- IF holding_stock_list.STOP_LOSS_REACHED -->							
							<span class="stop_loss_reached">  {holding_stock_list.STOP_LOSS_IN_PERCENT}% </span>
						<!-- ELSE -->
							<span class="stop_loss_not_reached"> {holding_stock_list.STOP_LOSS_IN_PERCENT}% </span>
						<!-- ENDIF -->									
					<!-- ENDIF -->								
				</span>
			</td>
			
			<td class="stop_loss_profit" >			
				<span id="holding-stop-profit-{holding_stock_list.CORP_ID}">			
					<!-- IF holding_stock_list.STOP_PROFIT != 0	  -->
						<img src="{T_IMAGES_PATH}up_bar.png"  width="12" height="12" /> 
							
						<!-- IF holding_stock_list.STOP_PROFIT_REACHED -->
							<span class="stop_loss_reached"> {holding_stock_list.STOP_PROFIT_IN_PERCENT}% </span>
						<!-- ELSE -->
							<span class="stop_loss_not_reached"> {holding_stock_list.STOP_PROFIT_IN_PERCENT}% </span>
						<!-- ENDIF -->	
					<!-- ENDIF -->			
				</span>
			</td>
			
			<td>
				<span >
					<a  href="javascript: void(0)"  
						onClick="openStopDialog('holding', '{holding_stock_list.CORP_ID}', '{holding_stock_list.CORP_NAME}', {holding_stock_list.STOP_LOSS}, {holding_stock_list.STOP_PROFIT}, {holding_stock_list.COST}, {holding_stock_list.REFERED_PRICE});">
						<img title="{L_SV_ASSET_LIST_TIP_EDIT_NOTE}" src="{T_IMAGES_PATH}pencil.png"  width="12" height="12" class='edit_note_icon'/> 
					</a>
				</span>					
			</td>
			<!-- ENDIF -->			
			
			<td title="{L_SV_ASSET_LIST_TIP_MORE_INFO}" class="more_info">
				<p>
				<a href="http://www.google.com.hk/finance?q=TPE:{holding_stock_list.CORP_ID}" target=_blank><img src="{T_IMAGES_PATH}G.png" width=24 height=24 class='more_info_icon'></a>
				<a href="http://tw.stock.yahoo.com/q/q?s={holding_stock_list.CORP_ID}" target=_blank><img src="{T_IMAGES_PATH}Y.png" width=24 height=24 class='more_info_icon'></a>				
				</p>
			</td>	
			
			<!-- IF S_SHOW_NOTE_IN_ASSET_LIST	  -->
			<td title="{L_SV_ASSET_LIST_TIP_NOTE}" class="edit_note" >
				<p> 					
					<span id="holding-note-{holding_stock_list.CORP_ID}">{holding_stock_list.NOTE} </span>
					
					<span style="float:right">
					<a  href="javascript: void(0)"  
						onClick="openDialog('holding', '{holding_stock_list.CORP_ID}', '{holding_stock_list.CORP_NAME}', '{holding_stock_list.NOTE}');">
						<img title="{L_SV_ASSET_LIST_TIP_EDIT_NOTE}" src="{T_IMAGES_PATH}pencil.png"  width="12" height="12" class='edit_note_icon'/> 
					</a>
					</span>
				</p>	
			</td>
			<!-- ENDIF -->			
			
		</tr>
		<!-- END holding_stock_list -->		
	</table>
	<!-- ENDIF -->
	
	
	<!-- IF S_SHORT_STOCK_LIST  -->
	<table border="0" cellpadding="5" cellspacing="5">
		<tr>
		<p>{L_SV_SHORT_STOCK}</p>
		</tr>
		<tr>
			<td><p>{L_SV_CORP_NAME}</p></td>
			<td title="{L_SV_ASSET_LIST_TIP_NUMBER}" class="share_number"><p>{L_SV_NUMBER}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_COST}" class="share_price"><p>{L_SV_COST}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_REFERED_PRICE}" class="share_price"><p>{L_SV_REFERED_PRICE}</p></td>						
			<td title="{L_SV_ASSET_LIST_TIP_DIFFERENCE_PRICE}" class="share_price_diff"><p>{L_SV_DIFFERENCE_PRICE}</p></td>	
			<td title="{L_SV_ASSET_LIST_TIP_GAIN_OR_LOSS}" class="market_value"><p>{L_SV_GAIN_OR_LOSS}</p></td>				
			<td title="{L_SV_ASSET_LIST_TIP_DEPOSIT}" class="market_value"><p>{L_SV_DEPOSIT}</p></td>	
						
			<!-- IF S_ALLOW_EDIT_STOP_LOSS_PROFIT	  -->					
			<td title="" class="stop_loss_profit"><p> {L_SV_STOP_LOSS} </p> </td>
			<td title="" class="stop_loss_profit"><p> {L_SV_STOP_PROFIT} </p> </td>
			<td title="" class="edit_stop_loss_profit"> </td>			
			<!-- ENDIF -->
			
			<td title="{L_SV_ASSET_LIST_TIP_MORE_INFO}" class="more_info"><p>{L_SV_MORE_INFO}</p></td>	
			
			<!-- IF S_SHOW_NOTE_IN_ASSET_LIST	  -->					
			<td title="{L_SV_ASSET_LIST_TIP_NOTE}" class="edit_note"><p> {L_SV_NOTE} </p> </td>
			<!-- ENDIF -->			
			
		</tr>
		<!-- BEGIN short_stock_list -->
		<tr>
			<td><p><a href=" http://mops.twse.com.tw/mops/web/t146sb03?step=1&firstin=1&off=1&keyword4=&code1=&TYPEK2=&checkbtn=&queryName=co_id&TYPEK=all&isnew=true&co_id={short_stock_list.CORP_ID}" target=_blank>{short_stock_list.CORP_NAME}({short_stock_list.CORP_ID})</a></p></td>
			<td title="{L_SV_ASSET_LIST_TIP_NUMBER}" class="share_number"><p>{short_stock_list.NUMBER}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_COST}" class="share_price"><p>{short_stock_list.COST}</p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_REFERED_PRICE}" class="share_price"><p><a href="http://mis.twse.com.tw/stock/fibest.jsp?stock={short_stock_list.CORP_ID}" target=_blank>{short_stock_list.REFERED_PRICE}</a></p></td>			
			<td title="{L_SV_ASSET_LIST_TIP_DIFFERENCE_PRICE}   ({short_stock_list.DIFFERENCE_PRICE_PERCENT}<!-- IF short_stock_list.COST != 0 -->%)<!-- ENDIF -->" class="share_price"><p>{short_stock_list.DIFFERENCE_PRICE} ({short_stock_list.DIFFERENCE_PRICE_PERCENT}<!-- IF short_stock_list.COST != 0 -->%)<!-- ENDIF --></p></td>
			<td title="{L_SV_ASSET_LIST_TIP_GAIN_OR_LOSS}" class="market_value"><p>{short_stock_list.GAIN_OR_LOSS}</p></td>
			<td title="{L_SV_ASSET_LIST_TIP_DEPOSIT}" class="market_value"><p>{short_stock_list.DEPOSIT}</p></td>
						
			<!-- IF S_ALLOW_EDIT_STOP_LOSS_PROFIT	  -->
			<td class="stop_loss_profit">
				<span id="shorting-stop-loss-{short_stock_list.CORP_ID}"> 
					<!-- IF short_stock_list.STOP_LOSS != 0	  -->
						<img src="{T_IMAGES_PATH}up_bar.png"  width="12" height="12" /> 
						<!-- IF short_stock_list.STOP_LOSS_REACHED != 0	  -->							
							<span class="stop_loss_reached"> {short_stock_list.STOP_LOSS_IN_PERCENT}% </span>
						<!-- ELSE -->
							<span class="stop_loss_not_reached"> {short_stock_list.STOP_LOSS_IN_PERCENT}% </span>
						<!-- ENDIF -->								
					<!-- ENDIF -->			
				</span>
			</td>
			
			<td>
				<span id="shorting-stop-profit-{short_stock_list.CORP_ID}"> 
					<!-- IF short_stock_list.STOP_PROFIT != 0	  -->
						<img src="{T_IMAGES_PATH}down_bar.png"  width="12" height="12" /> 
						<!-- IF short_stock_list.STOP_PROFIT_REACHED != 0	  -->							
							<span class="stop_loss_reached"> {short_stock_list.STOP_PROFIT_IN_PERCENT}% </span>
						<!-- ELSE -->
							<span class="stop_loss_not_reached">{short_stock_list.STOP_PROFIT_IN_PERCENT}%</span>
						<!-- ENDIF -->								
					<!-- ENDIF -->			
				</span>
			</td>
			
			<td>
				<a href="javascript: void(0)"  onClick="openStopDialog('shorting', '{short_stock_list.CORP_ID}', '{short_stock_list.CORP_NAME}', {short_stock_list.STOP_LOSS}, {short_stock_list.STOP_PROFIT}, {short_stock_list.COST}, {short_stock_list.REFERED_PRICE});";>   
					<img title="{L_SV_ASSET_LIST_TIP_EDIT_NOTE}" src="{T_IMAGES_PATH}pencil.png"  width="12" height="12" class='edit_note_icon'/> 
				</a>
			</td>
			<!-- ENDIF -->			
			
			<td title="{L_SV_ASSET_LIST_TIP_MORE_INFO}" class="more_info">
				<p>
				<a href="http://www.google.com.hk/finance?q=TPE:{short_stock_list.CORP_ID}" target=_blank><img src="{T_IMAGES_PATH}G.png" width=24 height=24 class='more_info_icon'></a>
				<a href="http://tw.stock.yahoo.com/q/q?s={short_stock_list.CORP_ID}" target=_blank><img src="{T_IMAGES_PATH}Y.png" width=24 height=24 class='more_info_icon'></a>
				</p>
			</td>	
			
			<!-- IF S_SHOW_NOTE_IN_ASSET_LIST	  -->
			<td title="{L_SV_ASSET_LIST_TIP_NOTE}" class="edit_note">
				<p>	
					<a href="javascript: void(0)"  onClick="openStoDialog('shorting', '{short_stock_list.CORP_ID}', '{short_stock_list.CORP_NAME}', '{short_stock_list.NOTE}');";>   
						<img title="{L_SV_ASSET_LIST_TIP_EDIT_NOTE}" src="{T_IMAGES_PATH}pencil.png"  width="12" height="12" class='edit_note_icon'/> 
					</a>
					<span id="shorting-note-{short_stock_list.CORP_ID}">{short_stock_list.NOTE} </span>
				</p>	
			</td>
			<!-- ENDIF -->			
			
			
			
		</tr>
		<!-- END short_stock_list -->		
	</table>
	<!-- ENDIF -->
	
	
	<!-- IF NOT_ALL_STOCK_SHOWED -->
	<p><a href="{HOLDING_STOCK_DETAIL_URL}" target=_blank>{L_SV_COMPLETED_INFO}</a>  </p>
	<!-- ENDIF -->
	
</div>	
	
	
<!-- IF S_SHOW_NOTE_IN_ASSET_LIST	  -->	
	
	<script>
	function openDialog(type, corp_id, corp_name, note ) {
			var str;
			
			$( "#note-dialog" ).data('type', type);
			$( "#note-dialog" ).data('corp_id', corp_id);
			
			// set title
			str			= '{L_SV_ASSET_LIST_EDIT_NOTE_DIALOG_TITLE} - ' + corp_id + ' ' + corp_name;
			$( "#note-dialog" ).dialog( "option", "title", str );
			
			// set note
			document.getElementById('corp_note').value = note;
						
			$( "#note-dialog" ).dialog( "open" );
		}
		
	$(function() {
				
		$( "#note-dialog" ).dialog({
			autoOpen: false,
			height: 200,
			width: 370,
			modal: true,
			buttons: {
				"{L_SV_OK}": function() {
					var bValid 		= true;					
					var corp_type	= $(this).data("type");
					var corp_id		= $(this).data("corp_id");					
					var corp_note 	= $( "#corp_note" );					
					var str;
										
					// validate
					//allFields.removeClass( "ui-state-error" );

					if ( bValid ) {						
						// update the note												
						if (corp_type == 'holding')
							str = 'holding-note-' + corp_id;
						else
							str = 'shorting-note-' + corp_id;
												
						document.getElementById(str).innerHTML = corp_note.val();
						
						// send out ajax request.						
						$.ajax({
						  type: 'POST',
						  url: '{T_IMAGES_PATH}../query.php',
						  data: { mode: 'edit_note', type: corp_type, user_id: {S_USER_ID}, corp_id:corp_id, note:corp_note.val() },						  
						  
						  success:function(data){
    							//alert(data);    						
  							}
						});
						
						$( this ).dialog( "close" );
					}
				},
				"{L_SV_CANCEL}": function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
				//allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});			
			
	});
	</script>





<div id="note-dialog" title="Edit Note">
	<p class="validateTips"></p>

	<form>
	<fieldset>
		
		<label for="corp_note" id="note_label"> <p>{L_SV_ASSET_LIST_EDIT_NOTE_DIALOG_LABEL} </p></label>
		<input type="text" name="corp_note" id="corp_note" MAXLENGTH='120' SIZE='50' />		
		
	</fieldset>
	</form>
</div>



<!-- ENDIF -->

<!-- IF S_ALLOW_EDIT_STOP_LOSS_PROFIT	  -->

<script>
	function openStopDialog(type, corp_id, corp_name, stop_loss, stop_profit, cost, refered_price) {
			var str;
			
			$( "#stop-dialog" ).data('type', type);
			$( "#stop-dialog" ).data('corp_id', corp_id);
			
			// set title
			str			= '{L_SV_STOP_LOSS_PROFIT_SETTING} - ' + corp_name + '(' + corp_id + ')';
			$( "#stop-dialog" ).dialog( "option", "title", str );
			
			str			= ' ' + corp_name + '(' + corp_id + ')';
			document.getElementById('corp_id_name').innerHTML = str;
			
			// set stop loss/profit
			setStopLossProfitIndex('set_stop_loss', stop_loss);
			setStopLossProfitIndex('set_stop_profit', stop_profit);

			// set cost and refered price 
			document.getElementById('cost_in_stop_loss_profit').innerHTML = cost;
			document.getElementById('price_in_stop_loss_profit').value = refered_price;			
			
			$( "#stop-dialog" ).dialog( "open" );
		}
		
	function setStopLossProfitIndex(id, value){
		
			if (value == 0.0)
			{
				document.getElementById(id).selectedIndex = 0;
			}
			else if (value == 0.05)
			{
				document.getElementById(id).selectedIndex = 1;
			}
			else if (value == 0.10)
			{
				document.getElementById(id).selectedIndex = 2;
			}
			else if (value == 0.15)
			{
				document.getElementById(id).selectedIndex = 3;
			}
			else if (value == 0.20)
			{
				document.getElementById(id).selectedIndex = 4;
			}
			else if (value == 0.25)
			{
				document.getElementById(id).selectedIndex = 5;
			}
			else if (value == 0.30)
			{
				document.getElementById(id).selectedIndex = 6;
			}
			else if (value == 0.40)
			{
				document.getElementById(id).selectedIndex = 7;
			}
			else if (value == 0.50)
			{
				document.getElementById(id).selectedIndex = 8;
			}
	}
		
	$(function() {
				
		$( "#stop-dialog" ).dialog({
			autoOpen: false,
			height: 350,
			width: 500,
			modal: true,
			buttons: {
				"{L_SV_OK}": function() {
					var bValid 		= true;					
					var corp_type	= $(this).data("type");
					var corp_id		= $(this).data("corp_id");					
					var set_stop_loss 		= $( "#set_stop_loss" );					
					var set_stop_profit 	= $( "#set_stop_profit" );					
					var str;
					var html_str = '';
										
					// validate
					//allFields.removeClass( "ui-state-error" );

					if ( bValid ) {						
																	
						if (corp_type == 'holding')
						{
							str = 'holding-stop-loss-' + corp_id;
							
							if (set_stop_loss.val() != 0)
							{
								val = set_stop_loss.val() * 100;
								
								html_str = ' <img src="{T_IMAGES_PATH}down_bar.png"  width="12" height="12" /> ' + val + '%'; 								
								document.getElementById(str).innerHTML = html_str;
							}
							else
							{
								document.getElementById(str).innerHTML = '';
							}
							
							str = 'holding-stop-profit-' + corp_id;
							
							if (set_stop_profit.val() != 0)
							{								
								val = set_stop_profit.val() * 100;
								
							 	html_str = ' <img src="{T_IMAGES_PATH}up_bar.png"  width="12" height="12" />  ' + val + '%';
							 	document.getElementById(str).innerHTML = html_str;
						 	}
						 	else
						 	{
							 	document.getElementById(str).innerHTML = '';
						 	}
						}
						else
						{
							str = 'shorting-stop-loss-' + corp_id;
							
							if (set_stop_loss.val() != 0)
							{								
								val = set_stop_loss.val() * 100;
								
								html_str = ' <img src="{T_IMAGES_PATH}up_bar.png"  width="12" height="12" /> ' + val + '%';
								document.getElementById(str).innerHTML = html_str;
							}
							else
							{
								document.getElementById(str).innerHTML = '';
							}
							
							str = 'shorting-stop-profit-' + corp_id;
							
							if (set_stop_profit.val() != 0)
							{								
								val = set_stop_profit.val() * 100;
								
							 	html_str = ' <img src="{T_IMAGES_PATH}down_bar.png"  width="12" height="12" />  ' + val + '%';
							 	document.getElementById(str).innerHTML = html_str;
						 	}
						 	else
						 	{
							 	document.getElementById(str).innerHTML = '';
						 	}
						}
						
						
						
						// send out ajax request.						
						$.ajax({
						  type: 'POST',
						  url: '{T_IMAGES_PATH}../query.php',
						  data: { mode: 'set_stop_loss_profit', type: corp_type, user_id: {S_USER_ID}, corp_id:corp_id, stop_loss:set_stop_loss.val(), stop_profit:set_stop_profit.val(), }, 
						  
						  success:function(data){
    							//alert(data);    						
  							}
						});
						
						$( this ).dialog( "close" );
					}
				},
				"{L_SV_CANCEL}": function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
				//allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});			
			
	});
	

	function set_stop_loss_change(item){
		
	}
	
	function set_stop_profit_change(item){
		
	}
	
	</script>
	
<div id="stop-dialog" title="Stop Loss Profit">
	<p class="validateTips"></p>

	<form>
	<p>{L_SV_STOP_LOSS_PROFIT_DESC}</p>
	<p><span id="corp_id_name"></span> {L_SV_STOP_LOSS_PROFIT_COST} <span id="cost_in_stop_loss_profit"></span> 
	
	<input type="hidden" id="price_in_stop_loss_profit" value=0/>
	
	
	<fieldset>		
		<label for="set_stop_loss" id="note_label"> <p>{L_SV_SET_STOP_LOSS_DESC}</p></label>
				
		<select name="set_stop_loss" id="set_stop_loss" class="row2" title="{L_SV_NUMBER}" onchange="set_stop_loss_change(this);">
			<OPTION VALUE="0.0" SELECTED>{L_SV_STOP_LOSS_PROFIT_NOT_SET_YET}</OPTION>
			<OPTION VALUE="0.05" >5% </OPTION>
			<OPTION VALUE="0.10" >10% </OPTION>
			<OPTION VALUE="0.15" >15% </OPTION>
			<OPTION VALUE="0.20" >20% </OPTION>
			<OPTION VALUE="0.25" >25% </OPTION>
			<OPTION VALUE="0.30" >30% </OPTION>			
			<OPTION VALUE="0.40" >40% </OPTION>
			<OPTION VALUE="0.50" >50% </OPTION>
		</select>		
	</fieldset>
	
	<fieldset>		
		<label for="set_stop_profit" id="note_label"> <p>{L_SV_SET_STOP_PROFIT_DESC}</p></label>
				
		<select name="set_stop_profit" id="set_stop_profit" class="row2" title="{L_SV_NUMBER}" onchange="set_stop_profit_change(this);">
			<OPTION VALUE="0.0" SELECTED>{L_SV_STOP_LOSS_PROFIT_NOT_SET_YET}</OPTION>
			<OPTION VALUE="0.05" >5% </OPTION>
			<OPTION VALUE="0.10" >10% </OPTION>
			<OPTION VALUE="0.15" >15% </OPTION>
			<OPTION VALUE="0.20" >20% </OPTION>
			<OPTION VALUE="0.25" >25% </OPTION>
			<OPTION VALUE="0.30" >30% </OPTION>			
			<OPTION VALUE="0.40" >40% </OPTION>
			<OPTION VALUE="0.50" >50% </OPTION>
		</select>		
	</fieldset>
	
	</form>
</div>
<!-- ENDIF -->